import java.util.*;

public class project {
    public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) {
        int sum=0;
        Map<Integer,Integer> map=new HashMap<>();
        for(int n : nums1){
            for(int m : nums2){
                map.put(n+m,map.getOrDefault(n+m,0)+1);
            }
        }
        for(int n : nums3){
            for(int m : nums4){
                if(map.containsKey(-n-m)){
                    sum+=map.get(-n-m);
                }
            }
        }
        return sum;
    }




















    public void setZeroes(int[][] matrix) {
        int row=matrix.length;
        int col=matrix[0].length;
        boolean[] booleans1=new boolean[row];
        boolean[] booleans2=new boolean[col];
        for(int i=0;i<row;i++){
            for(int j=0;j<col;j++){
                if(matrix[i][j]==0){
                    booleans1[i]=true;
                    booleans2[j]=true;
                }
            }
        }
        for(int i=0;i<row;i++){
            for(int j=0;j<col;j++){
                if(booleans1[i]||booleans2[j]){
                    matrix[i][j]=0;
                }
            }
        }
    }














    public String simplifyPath(String path) {
        Deque<String> stack=new ArrayDeque<>();
        String[] str=path.split("/");
        for(String s : str){
            if(s.equals("..")){
                if(!stack.isEmpty()){
                    stack.pollLast();
                }
            }else if(s.length()>0&&!s.equals(".")){
                stack.addLast(s);
            }
        }
        StringBuilder sb=new StringBuilder();
        if(stack.isEmpty()){
            sb.append('/');
        }else{
            while (!stack.isEmpty()){
                sb.append('/');
                sb.append(stack.pollFirst());
            }
        }
        return sb.toString();
    }
}
